package org.example.ychdp.service;

import org.example.ychdp.dao.TicketDao;
import org.example.ychdp.entity.Comment;
import org.example.ychdp.entity.Ticket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TicketService {
    @Autowired
    private TicketDao ticketDao;

    public List<Ticket> buyTicket(Integer concertid) {
        return ticketDao.selectCommentsByConcertId(concertid);
    }
    public Ticket getTicket(Integer id){
        return ticketDao.selectByPrimaryKey(id);
    }

    public void update(Ticket ticket) {
        ticket.setRemainingtickets(ticket.getRemainingtickets()-1);
        ticketDao.updateByPrimaryKey(ticket);
    }
}
